<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习</title>
    <script>
        //学生数组
        const arr = []

        function add(){
            const name = document.getElementById("name").value;
            arr.push(name);
            alert('添加成功')
        }

        function show(){
            document.getElementById("show").innerText = arr;
        }
    </script>
</head>
<body>
    <div>
        <input id="name" placeholder="输入学生姓名"/>
        <button onclick="add()">添加学生</button>
    </div>
    <div>
        <button onclick="show()">展示全部学生</button>
        <p id="show"></p>
    </div>
</body>
</html>